home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 52
/
Volume 52 - JOGO DISK .iso
/
Games
/
shopdrop.swf
/
scripts
/
__Packages
/
PackageHandler.as
< prev
next >
Wrap
Text File
|
2007-09-27
|
6KB
|
191 lines
class PackageHandler
{
static var ySpeed = 100;
var nPack = 5;
var cPack = 0;
var bGiftCard = false;
var baseTime = 5;
var nBonusRange = 10;
var cBonusTime = 0;
var baseBalanceTime = 15;
var nBalanceRange = 20;
var cBalanceTime = 0;
function PackageHandler(loc, mcVanishing)
{
this.location = loc;
this.oHandler = new smashing.ClipHandler(loc,2);
this.vanishing = mcVanishing;
var _loc3_ = loc._parent.mcPackageLeft;
var _loc5_ = loc._parent.mcPackageRight;
this.startY = _loc3_._y;
this.range = _loc5_._x - _loc3_._x;
this.startX = _loc3_._x;
if(_global.bBonusCard == true || _global.bBalance == true)
{
this.update = this.updateCards;
this.makeBonusTime();
this.makeBalanceTime();
}
else
{
this.update = this.updateNormal;
}
}
function updateNormal(nElapsed)
{
this.cPack += nElapsed;
if(this.cPack >= this.nPack)
{
this.cPack %= this.nPack;
this.addPackage();
}
var _loc4_ = this.oHandler.clips;
var _loc5_ = _loc4_.length;
var _loc3_ = undefined;
var _loc2_ = 0;
while(_loc2_ < _loc5_)
{
_loc3_ = _loc4_[_loc2_];
if(_loc3_ != null)
{
_loc3_.update(nElapsed);
}
_loc2_ = _loc2_ + 1;
}
}
function updateCards(nElapsed)
{
this.cPack += nElapsed;
if(this.cPack >= this.nPack)
{
this.cPack %= this.nPack;
this.addPackage();
}
this.cBonusTime += nElapsed;
if(this.cBonusTime >= this.nBonusTime)
{
this.cBonusTime = 0;
this.makeBonusTime();
this.addBonusCard();
}
this.cBalanceTime += nElapsed;
if(this.cBalanceTime >= this.nBalanceTime)
{
this.cBalanceTime = 0;
this.makeBalanceTime();
this.addBalanceIcon();
}
var _loc4_ = this.oHandler.clips;
var _loc6_ = _loc4_.length;
var _loc3_ = undefined;
var _loc2_ = 0;
while(_loc2_ < _loc6_)
{
_loc3_ = _loc4_[_loc2_];
if(_loc3_ != null)
{
_loc3_.update(nElapsed);
}
_loc2_ = _loc2_ + 1;
}
}
function addPackage()
{
var _loc2_ = this.oHandler.addClip("mcPickup");
_loc2_._y = this.startY;
_loc2_._x = this.startX + Math.floor(Math.random() * this.range);
_loc2_.direction = new smashing.Point(this.vanishing._x - _loc2_._x,this.vanishing._y - _loc2_._y);
_loc2_.origin = new smashing.Point(_loc2_._x,_loc2_._y);
_loc2_.distance2 = _loc2_.direction.dot(_loc2_.direction);
_loc2_.direction.normalizeMe();
_loc2_.lastY = _loc2_._y;
_loc2_.vanishing = this.vanishing;
if(this.bGiftCard == true)
{
_loc2_.toGiftCard();
}
else
{
_loc2_.a.pickup.gotoAndStop(Math.ceil(Math.random() * 5));
}
}
function addBonusCard()
{
var _loc2_ = this.oHandler.addClip("mcPickup");
_loc2_._y = this.startY;
_loc2_._x = this.startX + Math.floor(Math.random() * this.range);
_loc2_.direction = new smashing.Point(this.vanishing._x - _loc2_._x,this.vanishing._y - _loc2_._y);
_loc2_.origin = new smashing.Point(_loc2_._x,_loc2_._y);
_loc2_.distance2 = _loc2_.direction.dot(_loc2_.direction);
_loc2_.direction.normalizeMe();
_loc2_.lastY = _loc2_._y;
_loc2_.vanishing = this.vanishing;
_loc2_.toBonusCard();
}
function addBalanceIcon()
{
var _loc2_ = this.oHandler.addClip("mcPickup");
_loc2_._y = this.startY;
_loc2_._x = this.startX + Math.floor(Math.random() * this.range);
_loc2_.direction = new smashing.Point(this.vanishing._x - _loc2_._x,this.vanishing._y - _loc2_._y);
_loc2_.origin = new smashing.Point(_loc2_._x,_loc2_._y);
_loc2_.distance2 = _loc2_.direction.dot(_loc2_.direction);
_loc2_.direction.normalizeMe();
_loc2_.lastY = _loc2_._y;
_loc2_.vanishing = this.vanishing;
_loc2_.toBalanceIcon();
}
function reset()
{
this.cPack = 0;
this.oHandler.removeAllClips();
this.toPackages();
}
function toGiftCards()
{
this.bGiftCard = true;
var _loc4_ = this.oHandler.clips;
var _loc3_ = undefined;
var _loc2_ = 0;
while(_loc2_ < _loc4_.length)
{
_loc3_ = _loc4_[_loc2_];
if(_loc3_ != null)
{
if(_loc3_.nType == GrabPackage.NORMAL)
{
_loc3_.toGiftCard();
}
}
_loc2_ = _loc2_ + 1;
}
}
function toPackages()
{
this.bGiftCard = false;
var _loc4_ = this.oHandler.clips;
var _loc3_ = undefined;
var _loc2_ = 0;
while(_loc2_ < _loc4_.length)
{
_loc3_ = _loc4_[_loc2_];
if(_loc3_ != null)
{
if(_loc3_.nType == GrabPackage.NORMAL)
{
_loc3_.toPackage();
}
}
_loc2_ = _loc2_ + 1;
}
}
function makeBonusTime()
{
this.nBonusTime = this.baseTime + Math.floor(Math.random() * this.nBonusRange);
}
function makeBalanceTime()
{
this.nBalanceTime = this.baseBalanceTime + Math.floor(Math.random() * this.nBalanceRange);
}
}